﻿#include "SingleLinedList.h"

// 头部操作测试
void TestFrontHandle()
{
	ListNode* head = NULL;
	SingleListPushFront(&head, 1);
	SingleListPushFront(&head, 2);
	SingleListPushFront(&head, 3);
	SingleListPushFront(&head, 4);
	SingleListPushFront(&head, 5);

	SingleListPopFront(&head);
	SingleListPopFront(&head);
	SingleListPopFront(&head);

	SingleListTraverse(head);

	SingleListPopFront(&head);
	SingleListPopFront(&head);

	SingleListTraverse(head);
}

// 尾部操作测试
void TestBackHandle()
{
	ListNode* head = NULL;
	
	SingleListPushBack(&head, 1);
	SingleListPushBack(&head, 2);
	SingleListPushBack(&head, 3);
	SingleListPushBack(&head, 4);
	SingleListPushBack(&head, 5);

	SingleListTraverse(head);

	SingleListPopBack(&head);
	SingleListPopBack(&head);
	SingleListPopBack(&head);

	SingleListTraverse(head);

	SingleListPopBack(&head);
	SingleListPopBack(&head);

	SingleListTraverse(head);

}

// 中间操作测试
void TestMiddleHandle()
{
	ListNode* head = NULL;

	SingleListPushBack(&head, 1);
	SingleListPushBack(&head, 2);
	SingleListPushBack(&head, 3);
	SingleListPushBack(&head, 4);
	SingleListPushBack(&head, 5);

	SingleListInsertAfter(&head, 4, 999);
	SingleListInsertAfter(&head, 0, 888);

	SingleListTraverse(head);

	SingleListEraseAfter(&head, 0);
	SingleListEraseAfter(&head, 4);
	
	SingleListTraverse(head);

}

int main()
{
	// TestFrontHandle();
	// TestBackHandle();

	TestMiddleHandle();
	return 0;
}